package com.llbnk.srb.sms.util;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author shkstart
 * @create 2022-04-13 14:49
 */
@Data
@Component //spring程序就可以自动创建整个类的对象
// 根据ConfigurationProperties(prefix = "aliyun.sms")的一个参数，自动组装里面的值
@ConfigurationProperties(prefix = "tencent.sms")//读取配置文件注解读取的是aliyun.sms这部分
public class SmsTecentProperties implements InitializingBean {
    //对应application中的格式可以识别驼峰和-格式
    private String secretId;
    private String secretKey;
    private String sdkAppId;
    private String sdkAppKey;
    private String signName;
    private String templateId;

    public static String SECRET_ID;
    public static String SECRET_KEY;
    public static String SDK_APP_ID;
    public static String SDK_APP_KEY;
    public static String SIGN_NAME;
    public static String TEMPLATE_ID;

    /**
     * InitializingBean是spring提供的接口
     * 这个接口是afterPropertiesSet就是上面这个regionId参数被spring设置完成之后（Component注解负责）
     * 调用这个
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        SECRET_ID = secretId;
        SECRET_KEY = secretKey;
        SDK_APP_ID = sdkAppId;
        SDK_APP_KEY = sdkAppKey;
        SIGN_NAME = signName;
        TEMPLATE_ID = templateId;
    }
}
